<template>
  <div>
    <van-nav-bar title="资料与个人设置"
                 left-arrow
                 @click-left="onClickLeft" />
    <van-form @submit="onSubmit">
      <van-cell-group inset>
        <!-- <van-field v-model="user.userPortrait"
                   name="userPortrait"
                   label="头像"
                   placeholder="头像"
                   disabled /> -->
        <van-field v-model="user.userNickname"
                   name="userNickname"
                   label="昵称"
                   placeholder="请输入昵称"
                   disabled />
        <van-field v-model="user.userRealname"
                   name="userRealname"
                   label="真实姓名"
                   disabled />
        <van-field v-model="user.userId"
                   name="userId"
                   label="用户ID"
                   disabled />
        <van-field v-model="user.userSex"
                   name="userSex"
                   label="性别"
                   disabled />
        <van-field v-model="user.userGrade"
                   name="userGrade"
                   label="年级"
                   disabled />
        <van-field v-model="user.userSchool"
                   name="userSchool"
                   label="学校"
                   disabled />
        <!-- <van-field v-model="user.userPassword"
                   name="userPassword"
                   label="密码"
                   placeholder="请输入账号密码"
                   :rules="[{ required: true, message: '请设置账号密码' }]"
                   disabled /> -->
        <van-field v-model="user.userTel"
                   name="userTel"
                   label="手机号"
                   disabled />
      </van-cell-group>
      <!-- <div style="margin: 16px;">
        <van-button round
                    block
                    color="#87d4eb"
                    native-type="submit">
          提交修改
        </van-button>
      </div> -->
    </van-form>

  </div>
</template>
<script>
import { reactive, getCurrentInstance } from 'vue'
import { Toast } from 'vant'
import { localGet } from '../../../utils/auth'
export default {
  setup () {
    const { proxy } = getCurrentInstance()
    const data = reactive({

    })
    function onClickLeft () {
      window.history.length > 1 ? proxy.$router.go(-1) : proxy.$router.push('/user')
    }
    return {
      data,
      onClickLeft
    }
  },
  data () {
    return {
      user: {
        userId: 0,
        userPortrait: '',
        userNickname: '',
        userRealname: '',
        userUid: '',
        userTel: '',
        userGroup: 1,
        userSex: 1,
        userPassword: ''
      }
    }
  },
  created () {
    this.getUser()
  },
  methods: {
    getUser () {
      this.user = localGet('STEM_USER_INFO')
    },
    onSubmit (values) {
      this.$axios.user.changeNick(this.user.userNickname).then(res => {
        if (res.status === 200) {
          Toast('修改成功')
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
